#include <iostream>

using namespace std;

class CFraction
{
private:
    int fz, fm;

public:
    CFraction()
    {
        fz = 0;
        fm = 1;
        cout << "Constructor." << endl;
    }
    CFraction(int fz_val, int fm_val);
    CFraction add(const CFraction &r);
    CFraction sub(const CFraction &r);
    CFraction mul(const CFraction &r);
    CFraction div(const CFraction &r);
    int getGCD();
    void print();
};

CFraction::CFraction(int fz_val, int fm_val)
{
    fz = fz_val;
    fm = fm_val;
}

CFraction CFraction::add(const CFraction &r)
{
    CFraction result(fz * r.fm + r.fz * fm, fm * r.fm);
    return result;
}

CFraction CFraction::sub(const CFraction &r)
{
    CFraction result(fz * r.fm - r.fz * fm, fm * r.fm);
    return result;
}

CFraction CFraction::mul(const CFraction &r)
{
    CFraction result(fz * r.fz, fm * r.fm);
    return result;
}

CFraction CFraction::div(const CFraction &r)
{
    CFraction result(fz * r.fm, fm * r.fz);
    return result;
}

void CFraction::print()
{
    int a = getGCD();
    cout << fz / a << "/" << fm / a << endl;
}

int CFraction::getGCD()
{
    int a = fz, b = fm;
    if (fz < 0)
    {
        a = -fz;
    }
    if (fm < 0)
    {
        b = -fm;
    }
    while (b != 0)
    {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int fz1, fm1, fz2, fm2;
        scanf("%d/%d %d/%d", &fz1, &fm1, &fz2, &fm2);
        CFraction f1(fz1, fm1), f2(fz2, fm2);
        CFraction f3 = f1.add(f2);
        CFraction f4 = f1.sub(f2);
        CFraction f5 = f1.mul(f2);
        CFraction f6 = f1.div(f2);
        f3.print();
        f4.print();
        f5.print();
        f6.print();
        cout << endl;
    }
    return 0;
}

/*

*/